/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package it.mdc.hearts.war.room.core;

import java.io.Serializable;

/**
 *
 * @author Administrator
 */
public class UserInfo implements Serializable{
    
    private final String[] userStatus = {"Free", "Watching", "Waiting", "Playing"};
    
    final int FREE = 0;
    final int WATCH = 1;
    final int WAIT = 2;
    final int PLAY = 3;
    
    private Integer userID;
    private String username;
    private Integer score;
    private String status;
    private GameTable currentTable;

    public UserInfo() {
        currentTable = null;
    }

    public Integer getUserID() {
        return userID;
    }

    public void setUserID(Integer userID) {
        this.userID = userID;
    }
    
    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public Integer getScore() {
        return score;
    }

    public void setScore(Integer score) {
        this.score = score;
    }

    public GameTable getCurrentTable() {
        return currentTable;
    }

    public void setCurrentTable(GameTable currentTable) {
        this.currentTable = currentTable;
    }

    public String getStatus() {
        int statusCode = FREE;
        
        if(currentTable != null)
        {
            if(!currentTable.isPlayer(userID))
            {
                statusCode = WATCH;
            }
            else
            {
                statusCode = PLAY;
                if(currentTable.getTableStatus() == currentTable.WAIT)
                {
                    statusCode = WAIT;
                }
            }
        }
        status = userStatus[statusCode];
        return status;
    }
}
